//显示评论列表
function getCommentList(page) {
    request({
        type: "get",
        url: "http://localhost:8080/api/v1/admin/comment/search",
        data: { page, perpage: 8 },
        success: (res) => {
            console.log(res);
            if (res.code === 200) {
                const htmlStr = template('commentTemplate', res.data)
                $('tbody').html(htmlStr)
                initPagination(res.data.totalPage)
            }
        }
    })
}
getCommentList()
const global = {}
function initPagination(total) {
    $('#pagination').twbsPagination({
        totalPages: total, // 总的页数
        visiblePages: 7, // 显示多少页
        first: '首页',
        last: '末页',
        prev: '上一页',
        next: '下一页',
        onPageClick: (event, page) => {
            getCommentList(page);
            global.page = page
        }
    });
}
//删除评论
function deleteCommentList(id) {
    request({
        type: "post",
        url: "http://localhost:8080/api/v1/admin/comment/delete",
        data: { id },
        success: (res) => {
            if (res.code === 200) {
                alert(res.msg)
                getCommentList(global.page)
            }
        }
    })
}
//评论审核通过
function passCommentList(id) {
    request({
        type: "post",
        url: "http://localhost:8080/api/v1/admin/comment/pass",
        data: { id },
        success: (res) => {
            if (res.code === 200) {
                alert(res.msg)
                getCommentList(global.page)
            }
        }
    })
}
//评论审核不通过
function rejectCommentList(id) {
    request({
        type: "post",
        url: "http://localhost:8080/api/v1/admin/comment/reject",
        data: { id },
        success: (res) => {
            if (res.code === 200) {
                alert(res.msg)
                getCommentList(global.page)
            }
        }
    })
}
